package com.itheima_01.day05;

public class printArray {
    public static void main(String[] args) {
        int[] arr = {11, 22, 33, 44, 55};
        pArray(arr);

        int[] getMaxAndMin=getMaxAndMin(arr);
        System.out.println("数组中最大值为："+getMaxAndMin[0]);
        System.out.println("数组中最小值为："+getMaxAndMin[1]);
    }

    public static void pArray(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                System.out.println(arr[i] + "]");
            } else {
                System.out.print(arr[i] + ", ");
            }
        }
    }

    public static int[] getMaxAndMin(int[] arr){

        int max=arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max<arr[i]){
                max=arr[i];
            }
        }
        int min=arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (min>arr[i]){
                min=arr[i];
            }
        }
        int[] getMaxAndMin={max,min};
        return getMaxAndMin;
    }


}
